﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VRAEWeb.Models;
using VRAEWeb.VRAEContribuyente;

namespace VRAEWeb.Controllers
{
    public class PagoPredialController : Controller
    {
        public ActionResult Index(String sCodigoContribuyente)
        {
            VRAEPago.SPagoClient oSPagoClient = new VRAEPago.SPagoClient();
            VRAEPago.Pago[] listaPagos = oSPagoClient.obtenerPagosPredial(sCodigoContribuyente);

            Session["PAgosPredial"] = listaPagos;

            return View(listaPagos);
        }

        [HttpPost]
        public ActionResult Index(FormCollection formCollection)
        {
            List<VRAEPago.Pago> listaPagoPendiente = new List<VRAEPago.Pago>();

            VRAEPago.Pago[] listaPagos = (VRAEPago.Pago[])Session["PAgosPredial"];

            int iConta = 0;

            foreach (var key in formCollection.AllKeys)
            {
                if (key.Contains("Seleccionar"))
                    if (formCollection[key] != "false")
                        listaPagoPendiente.Add(listaPagos[iConta]);
                iConta ++;
            }

            Session["PagosSeleccionados"] = listaPagoPendiente;

            return RedirectToAction("Index","Pago");
        }
    }
}
